import service from "@/requset/requset.js";

export function getArticleList(data) {
    return service({
        url: '/article/list',
        method: 'post',
        data: data
    })
}

export function addArticle(formData) {
    return service({
        url: '/article/add',
        method: 'post',
        data: formData
    })
}

export function deleteArticle(id) {
    return service({
        url: '/article/delete',
        method: 'post',
        data: id

    })
}

export function getArticlePages(data) {
    return service({
        url: '/article/listPage',
        method:"post",
        data:data
    })
}
export function getArticleListAll(data) {
    return service({
        url: '/article/listAll',
        method:"post",
        data:data
    })
}

export function uploadAvatar(data, onUploadProgress) {
    return service({
        url: '/system/uploadImg',
        method: 'post',
        data: data,
        timeout: 100000,
        headers: {
            'Content-Type': 'multipart/form-data' // 设置请求头
        },
        onUploadProgress
    })
}

export function getArticleById(id) {
    return service({
        url: '/article/getById',
        params: {
            id: id
        }
    })
}

export function subscribeArticle(data) {
    return service({
        url: '/article/subscribe',
        method: 'post',
        data: data
    })
}

export function getSubscribeArticle() {
    return service({
        url: '/article/getSubscribeArticle',
    })
}

export function deleteSubscribe(id, articleId) {
    return service({
        url: '/article/deleteSubscribeArticle',
        params: {
            id: id,
            articleId: articleId
        }
    })
}

export function likeArticle(data) {
    return service({
        url: '/article/like',
        method: "post",
        data: data,
    })
}

export function getSearchArticleApi(name) {
    return service({
        url: '/article/search',
        params: {
            name: name
        }
    })
}

export function articleBanApi(id,status){
    return service({
        url: '/article/articleBan',
        params: {
            articleId:id,
            status:status
        }
    })
}
export function toTopApi(data){
    return service({
        url: '/article/toTop',
        method:"POST",
        data:data
    })
}